#hkmule
require 'hpricot'
require 'open-uri'
require 'iconv'

def hkmule cname
	i = Iconv.new 'utf-8','gb2312'
	cname = i.iconv cname
	i.close
	hkmule_utf8 cname
end
def hkmule_utf8 cname
	url = 'http://www.hkmule.com/w/index.php?title='+cname+'&variant=zh-cn'
	as=[]
	uri =  URI::encode url
	begin
		doc = Hpricot open uri
		#puts doc
		(doc/'tr').each{|tr|
			a = tr.at('td/b/a')
			next if a==nil
			if a.html=='类型'
				(tr/'a').each{|a|
					as<<a.html
				}
				break
			end
		}
	rescue Interrupt=>e
		as<<'neterr'
	rescue 
	end
	as =['empty']if as.length<1
	as	
end